package com.snape.dao;

import com.snape.entity.Room;
import com.snape.entity.Room_Category;
import org.apache.ibatis.annotations.Param;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * Created by liuqingcan_snape on 2017/3/30.
 */
public interface RoomDao {
    /**
    查询和category有关的
    */
    /**
     * 数据库表名有问题,在设计api的时候已经改正了,特此记录
     * no: user_videos    yes: user_rooms
     * no: video_category yes: room_category
     */


    /**
     * 根据分类名称查询分类主键
     * @param name
     * @return categoryId
     * @throws Exception
     */
    public Integer selectCategoryIdByRoomCategoryName(@Param("categoryName") String name) throws Exception;

    /**
     * 根据分类名称查询分类实体（理论上应该使用分类主键的）
     * @param name
     * @return Room_Category实体
     * @throws Exception
     */
    public Room_Category selectCategoryInfoByCategoryName(@Param("categoryName") String name) throws Exception;


    /**
     * 根据分类主键查询分类实体 （理论上应该使用当前Api）
     * @param id
     * @return Room_Category实体
     * @throws Exception
     */
    public Room_Category selectCategoryInfoByCategoryId(@Param("categoryId") int id) throws Exception;


    /**
     * 查询所有的分类信息
     * @return
     * @throws Exception
     */
    public List<Room_Category> selectAllCategory() throws Exception;






    /**
    查询和Room_info有关的
     */


    /**
     * 分页查询,按时间排序查询出该分类下最优先的10条数据
     * @param id
     * @return List<Room>
     * @throws Exception
     */
    public List<Room> selectOnePageRoomByCategoryId(@Param("categoryId") int id) throws Exception;

    /**
     *  根据分页number,查询出视频房间(课程)数据
     * @param id
     * @param beginNumber
     * @param countNumber
     * @return
     * @throws Exception
     */
    public List<Room> selectRoomByCategotyidAndPagenumber
                            (@Param("categoryId")int id , @Param("beginNumber")int beginNumber,
                             @Param("countNumber") int countNumber) throws Exception;

    /**
     *  查询出roomID,以此可以取出属于该room的所有详细课程信息
     * @param name
     * @return
     * @throws Exception
     */
    public Integer selectRoomIdByRoomName(@Param("roomName") String name) throws Exception;

    /**
     * 查询课程有效期
     * @param id
     * @return  ex:有效期至2017-03-08
     * @throws Exception
     */
    public String selectValidDateByRoomId(@Param("roomId")int id) throws Exception;


    /**
     * 查询该分类有多少条数据
     * @param Id
     * @return
     * @throws Exception
     */
    public Integer selectCountRoomByCategoryId(@Param("categoryId") int Id) throws Exception;

    /**
     * 插入新建房间的信息
     * @param room
     * @throws Exception
     */
    public void insertRoomInfo(@Param("room")Room room) throws Exception;

    /**
     * 查找最新的id
     * @return
     * @throws Exception
     */
    public Integer selectLastId() throws Exception;
}
